package Collection;

import java.util.LinkedList;

/*
    LinkedList为双向链表
 */
public class LinkedListDemo {
    public static void main(String[] args) {
        LinkedList<String> linkedList=new LinkedList<>();
        linkedList.add("a");
        linkedList.add("b");
        linkedList.add("c");
        System.out.println(linkedList);
        linkedList.addFirst("r");
        linkedList.addLast("t");
        System.out.println(linkedList);
        System.out.println(linkedList.getFirst());
        System.out.println(linkedList.getLast());
        System.out.println(linkedList.remove("b"));
        System.out.println(linkedList.remove(1));
        while (!linkedList.isEmpty()){
            linkedList.pop();//从此链表表示的栈中弹出一个元素
        }
        System.out.println(linkedList);
    }
}
